package com.lock;

public class Main {
    public static void main(String[] args) {
        Ticket ticket = new Ticket();

        //模拟三个售票窗口
        for (int i = 0; i < 3; i++) {
            int finalI = i;
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int j = 0; j < 30; j++) {
                        Integer integer = ticket.saleTicket();
                        if (integer == null) {
                            System.out.println("已售空");
                            break;
                        } else {
                            System.out.println("窗口" + finalI + " -- 售出--" + integer);

                        }
                    }
                }
            }, "窗口" + i);
            thread.start();
        }
    }
}
